4 import java.awt.event.ActionEvent;
5 import java.awt.event.ActionListener;
6 import java.rmi.Naming;
7 import java.rmi.RemoteException;
9 import javax.swing.JButton;
10 import javax.swing.JFrame;
11 import javax.swing.JLabel;
12 import javax.swing.JPanel;
13 import javax.swing.JTextField;
14 import javax.swing.border.EmptyBorder;
16 import common.AdminInterface;
18 import configuration.___IntNames;
21 public class OwnerRegistrationGUI extends JFrame {
24 private JTextField nameField;
25 private JTextField userNameField;
26 private AdminInterface am = null;
27 private JTextField passField;
28 private JTextField bank1Field;
29 private JTextField bank2Field;
30 private JTextField bank3Field;
31 private JTextField bank4Field;
32 private JTextField emailField;
33 private JLabel lblWhenAcceptedYou;
34 private JLabel feedback;
39 public OwnerRegistrationGUI() {
42 am = (AdminInterface) Naming
43 .lookup(___IntNames.AdminManager);
44 } catch (Exception e1) {
45 System.out.println("Error accessing remote authentication: "
48 setTitle("Owner registration");
49 setBounds(100, 100, 500, 400);
51 panel.setBorder(new EmptyBorder(5, 5, 5, 5));
52 setContentPane(panel);
53 panel.setLayout(null);
55 JLabel nameLb = new JLabel("Name:");
56 nameLb.setBounds(37, 45, 46, 14);
59 nameField = new JTextField();
60 nameField.setBounds(147, 42, 86, 20);
62 nameField.setColumns(10);
64 JLabel lblUsername = new JLabel("Username:");
65 lblUsername.setBounds(37, 212, 69, 14);
66 panel.add(lblUsername);
68 userNameField = new JTextField();
69 userNameField.setBounds(147, 209, 86, 20);
70 panel.add(userNameField);
71 userNameField.setColumns(10);
73 JLabel lblPassword = new JLabel("Password:");
74 lblPassword.setBounds(37, 258, 69, 14);
75 panel.add(lblPassword);
77 passField = new JTextField();
78 passField.setBounds(147, 255, 86, 20);
80 passField.setColumns(10);
82 JLabel lblBankAccount = new JLabel("Bank account:");
83 lblBankAccount.setBounds(37, 94, 69, 14);
84 panel.add(lblBankAccount);
86 bank1Field = new JTextField();
87 bank1Field.setBounds(147, 91, 61, 20);
88 panel.add(bank1Field);
90 bank2Field = new JTextField();
91 bank2Field.setBounds(218, 91, 61, 20);
92 panel.add(bank2Field);
94 bank3Field = new JTextField();
95 bank3Field.setBounds(289, 91, 32, 20);
96 panel.add(bank3Field);
98 bank4Field = new JTextField();
99 bank4Field.setBounds(331, 91, 117, 20);
100 panel.add(bank4Field);
102 JButton btnSendRegistrationRequest = new JButton(
103 "Send registration request");
104 btnSendRegistrationRequest.setBounds(127, 316, 194, 23);
105 btnSendRegistrationRequest.addActionListener(new ActionListener() {
106 public void actionPerformed(ActionEvent arg0) {
108 jButton_ActionPerformed(arg0);
112 panel.add(btnSendRegistrationRequest);
114 JLabel lblEmail = new JLabel("E-mail:");
115 lblEmail.setBounds(37, 155, 46, 14);
118 emailField = new JTextField();
119 emailField.setBounds(147, 152, 148, 20);
120 panel.add(emailField);
121 emailField.setColumns(10);
123 lblWhenAcceptedYou = new JLabel(
124 "When accepted you will receive an e-mail");
125 lblWhenAcceptedYou.setForeground(Color.GREEN);
126 lblWhenAcceptedYou.setBounds(127, 291, 214, 14);
127 panel.add(lblWhenAcceptedYou);
129 feedback = new JLabel("");
130 feedback.setForeground(Color.RED);
131 feedback.setEnabled(false);
132 feedback.setBounds(127, 344, 214, 20);
136 private void jButton_ActionPerformed(ActionEvent e) {
138 Owner own = new Owner(this.nameField.getText(),
139 this.bank1Field.getText() + " " + this.bank2Field.getText()
140 + " " + this.bank3Field.getText() + " "
141 + this.bank4Field.getText(), this.emailField.getText());
145 if (this.am.addAccountRequest(this.userNameField.getText(),
146 this.passField.getText(), own)) {
147 this.am.saveInstance();
148 this.feedback.setText("Request sended");
150 this.feedback.setText("Can't send the request");
152 } catch (RemoteException e1) {
153 // TODO Auto-generated catch block
154 e1.printStackTrace();